<template>
  <div class="header">
    <div class="left" @click="goHome">
      <div class="logo">
        <img src="../assets/logo.png" width="60px" height="60px" alt="" />
      </div>
      <div class="title">
        <span class="title-text">办公软件视频在线学习网站</span>
      </div>
    </div>
    <div class="right">
      <span class="p">欢迎您,{{ userInfo.username }} </span>
      <span>丨</span>
      <span class="p" @click="goUserInfo">个人中心</span>
      <span>丨</span>
      <span class="p" @click="logout">重新登录</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userInfo: JSON.parse(localStorage.getItem("userInfo")),
    };
  },
  methods: {
    goHome() {
      this.$router.push({path:'/'})
    },
    goUserInfo(){
      this.$router.push({path:'/user'})
    },
    logout(){
      localStorage.removeItem("userInfo")
      this.$message({
        message: "退出登录"
      });
      this.$router.push({path:'/login'})
    }
  },
};
</script>

<style lang="scss" scoped>
.header {
  width: 100%;
  height: 100px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 0 50px;
  box-sizing: border-box;
  align-items: center;

  .left {
    display: flex;
    align-items: center;
    cursor: pointer;
    .logo {
      width: 60px;
      height: 60px;
      margin: 20px 0 20px 30px;
      border-radius: 60px;
      overflow: hidden;
    }
    .title {
      font-family: "楷体";
      font-weight: 600;
    }
  }
  .right {
    cursor: pointer;
    font-size: 13px;
    .p{
        &:hover{
            color: rgb(54, 54, 243);
        }
    }
  }
}
</style>
